//
//  PersonMessageTableViewCell.m
//  XiangMuB
//
//  Created by lanou3g on 16/8/13.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "PersonMessageTableViewCell.h"

@implementation PersonMessageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
       
        [self setupSubviews];
        
    }
    
    return self;
}


- (void)setupSubviews{
    
    self.userImageView = [[UIImageView alloc] init];
    self.userImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"3.jpg"]];
    [self.contentView addSubview:self.userImageView];
    
    self.usernameLabel = [[UILabel alloc] init];
    self.usernameLabel.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.usernameLabel];
    
    self.timeLabel = [[UILabel alloc] init];
    self.timeLabel.backgroundColor = [UIColor purpleColor];
    [self.contentView addSubview:self.timeLabel];
    
    self.contentLabel = [[UILabel alloc] init];
    self.contentLabel.backgroundColor = [UIColor orangeColor];
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.text = @"dsfgdsfsfadafdfsssdgsdfgdsgdsfsgsd阿里复活卡时间浪费爱上发送发送发了疯安抚阿里发了疯安抚爱上分拉风爱上发牢骚发牢骚发送分安抚奥拉夫爱上发送分撒发生了纠纷都是佛挡杀佛规范的方式广东省高第三个四个山东；垃圾管理；上课归档；算了广告牌等几十个了；看对方是个代理商了算了；第几个了；山东";
    [self.contentView addSubview:self.contentLabel];
    
    self.showImageview = [[UIView alloc] init];
    self.showImageview.backgroundColor = [UIColor blueColor];
    
    [self.contentView addSubview:self.showImageview];
    
    self.bottomView = [[UIView alloc] init];
    self.bottomView.backgroundColor = [UIColor greenColor];
    
    [self.contentView addSubview:self.bottomView];
    
    self.tagLabel = [[UILabel alloc] init];
    self.tagLabel.backgroundColor = [UIColor redColor];
    
    [self.contentView addSubview:self.tagLabel];
    

}

- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    CGFloat margin = 10;
    self.userImageView.frame = CGRectMake(10, 10, 50, 50);
    self.usernameLabel.frame = CGRectMake(CGRectGetMaxX(self.userImageView.frame) + margin, self.userImageView.frame.origin.y, 100, 30);
    self.timeLabel.frame = CGRectMake(self.contentView.frame.size.width - margin - 100, self.userImageView.frame.origin.y, 100, 30);
    self.contentLabel.frame = CGRectMake(self.usernameLabel.frame.origin.x, CGRectGetMaxY(self.userImageView.frame) + 10, self.contentView.frame.size.width - 3 * margin - self.userImageView.frame.size.width - 30,100);
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, self.contentView.frame.size.height - 1, self.contentView.frame.size.width, 1)];
    lineView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:lineView];
    
    self.bottomView.frame = CGRectMake(0, self.contentView.frame.size.height - 45, self.contentView.frame.size.width, 44);
    
    self.showImageview.frame = CGRectMake(CGRectGetMinX(self.contentLabel.frame), CGRectGetMaxY(self.contentLabel.frame) + 10, self.contentLabel.frame.size.width, 100);
    
    self.tagLabel.frame = CGRectMake(0, CGRectGetMinY(self.bottomView.frame) - 40, self.contentView.frame.size.width, 40);
    
    
    
    
    
}

- (void)setModel:(CellContentModel *)model{
    
    if (_model != model) {
        
        _model = model;
        
//        _contentLabel.text = model.contentString;
        
       
        
    }
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
